/**
 * 更新成功后回调函数
 */
function forwardFunc() {
	window.location.href = context
			+ '/system/tablequery/jsplist.jsp?queryKey=sqlist';
}

/**
 * 初始化form表单项
 * 
 * @param {}
 *            json
 */
function initFunc(json) {
	
	if (json != null && json.success == true) {
		$('CARSQ_ID').value = json.data.CARSQ_ID;
		$('CARSQ_UNIT').value = json.data.CARSQ_UNIT;
		$('CARSQ_UNITID').value = json.data.CARSQ_UNITID;
		$('CARSQ_USER').value = json.data.CARSQ_USER;
		$('CARSQ_USERID').value = json.data.CARSQ_USERID;
		$('CARSQ_CL').value = json.data.CARSQ_CL;
		$('CARSQ_CLID').value = json.data.CARSQ_CLID;
		$('CARSQ_TEL').value = json.data.CARSQ_TEL;
		$('CARSQ_CCRW').value = json.data.CARSQ_CCRW;
		$('CARSQ_QXYT').value = json.data.CARSQ_QXYT;
		$('CARSQ_XSLC').value = json.data.CARSQ_XSLC;
		$('CARSQ_KSSJ').value = formatDate(json.data.CARSQ_KSSJ.substring(0, 8))
				+ ' '
				+ json.data.CARSQ_KSSJ.substring(8, 10)
				+ ':'
				+ json.data.CARSQ_KSSJ.substring(10, 12);
		$('CARSQ_JZSH').value = formatDate(json.data.CARSQ_JZSH.substring(0, 8))
				+ ' '
				+ json.data.CARSQ_JZSH.substring(8, 10)
				+ ':'
				+ json.data.CARSQ_JZSH.substring(10, 12);
		$('CARSQ_RS').value = json.data.CARSQ_RS;
		$('CARSQ_XZ').value = json.data.CARSQ_XZ;
		$('CARSQ_MEMO').value = json.data.CARSQ_MEMO;
		$('CARSQ_DJR').value = json.data.CARSQ_DJR;
		$('CARSQ_DJRID').value = json.data.CARSQ_DJRID;
		$('CARSQ_DATE').value = json.data.CARSQ_DATE;
		$('CARSQ_STATUS').value = json.data.CARSQ_STATUS;
		$('CARSQ_YY').value = json.data.CARSQ_YY;

		if ($('STAMP_NO')) {
			$('STAMP_NO').value = json.data.STAMP_NO;
		}
		if ($('STAMP_COUNT')) {
			$('STAMP_COUNT').value = json.data.STAMP_COUNT;
		}
		$('JSY_XM').value = json.data.JSY_XM;
		$('STAMP_FP').value = json.data.STAMP_FP;
		$('STAMP_KC').value = json.data.STAMP_KC;
		$('STAMP_ID').value = json.data.STAMP_ID;
		
	}
}

/**
 * 审批通过
 */
function spyes() {
	Ext.MessageBox.confirm('提示', '确定审核通过？', function(e) {
				if (e == "yes") {
					Ext.MessageBox.wait('提交处理过程中...');
					var params = {};
					var params_yp = {};
					params.CARSQ_ID = $('CARSQ_ID').value;
					params.CARSQ_STATUS = '1';
					
					var yp_ck = document.form1.STAMP_FP.value*1;
					var yp_kcnum = document.form1.STAMP_KC.value*1;
					var dq_kum=0;
					
					if(yp_ck>yp_kcnum){}
					else{
						dq_kum = yp_kcnum - yp_ck;
					}
					params_yp.STAMP_ID = $('STAMP_ID').value;;
					params_yp.STAMP_KC = dq_kum;
					//alert("dq_kum==="+dq_kum);
					//alert("params_yp.STAMP_ID==="+params_yp.STAMP_ID);
					
					updateColumn('APP_CARSQ', 'single', '', params, null,
							function() {
								updateColumn('APP_CARSTAMP', 'single', '', params_yp, null,
								    function(){	
										forwardFunc();
								    })
					});
				}
			});
}

function spno() {
	Ext.MessageBox.show({
				title : '审核未通过',
				msg : '请填写回复内容:',
				width : 300,
				buttons : Ext.MessageBox.OKCANCEL,
				multiline : true,
				fn : function(btn, text) {
					if (btn == 'ok') {
						Ext.MessageBox.wait('提交处理过程中...');
						var params = {};
						params.CARSQ_ID = $('CARSQ_ID').value;
						params.CARSQ_YY = text;
						params.CARSQ_STATUS = '-1';

						updateColumn('APP_CARSQ', 'single', '', params, null,
								function() {
									forwardFunc();
								});
					}
				}
			});
}